//
//  MYFactoryManager.m
//  GoHiking_app
//
//  Created by qf on 15/10/13.
//  Copyright (c) 2015年 qf. All rights reserved.
//

#import "MYFactoryManager.h"
#import "GTMBase64.h"
#import "TabBarViewController.h"

@implementation MYFactoryManager

#pragma mark -- 计算高度
+ (CGFloat)heightForString:(NSString *)string fontSize:(CGFloat)fontSize andWidth:(CGFloat)width{
    CGRect rect = [string boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]} context:nil];
    return rect.size.height;
}

+ (CGFloat)widthForString:(NSString *)string fontSize:(CGFloat)fontSize andHeight:(CGFloat)height{
    CGRect rect = [string boundingRectWithSize:CGSizeMake(MAXFLOAT, height) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]} context:nil];
    
    return rect.size.width;
}

#pragma mark -- 时间
+ (NSString *)getStartTimeDate:(double)dateTime format:(NSString *)format{
    if (format == nil) {
        format = @"yyyy/MM/dd";
    }
    NSTimeInterval time= dateTime;//因为时差问题要加8小时 == 28800 sec
    NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time];
    //实例化一个NSDateFormatter对象
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    //设定时间格式,这里可以设置成自己需要的格式 @"yyyy/MM/dd"
    [dateFormatter setDateFormat:format];
    NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];
    return currentDateStr;
}
/*处理返回应该显示的时间*/
+ (NSString *) returnUploadTime:(NSString *)timeStr
{
    NSTimeInterval time= [timeStr doubleValue];//因为时差问题要加8小时 == 28800 sec
    NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time];
    //实例化一个NSDateFormatter对象
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    //设定时间格式,这里可以设置成自己需要的格式
    [dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];
    NSDate *datenow = [NSDate date];
    NSDateFormatter * dm = [[NSDateFormatter alloc]init];
    //指定输出的格式   这里格式必须是和上面定义字符串的格式相同，否则输出空
    [dm setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSDate * newdate = [dm dateFromString:currentDateStr];
    long dd = (long)[datenow timeIntervalSince1970] - [newdate timeIntervalSince1970];
    NSString *timeString=@"";
    if (dd/3600<1)
    {
        timeString = [NSString stringWithFormat:@"%ld", dd/60];
        timeString=[NSString stringWithFormat:@"%@分钟前", timeString];
    }
    if (dd/3600>1&&dd/86400<1)
    {
        timeString = [NSString stringWithFormat:@"%ld", dd/3600];
        timeString=[NSString stringWithFormat:@"%@小时前", timeString];
    }
    if (dd/86400>1)
    {
        timeString = [NSString stringWithFormat:@"%ld", dd/86400];
        timeString=[NSString stringWithFormat:@"%@天前", timeString];
    }
    return timeString;
}
//返回时间戳
+ (NSString *)returnTimestamp:(NSString *)timeStr{
    //实例化一个NSDateFormatter对象
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    //设定时间格式,这里可以设置成自己需要的格式
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    NSDate *date = [dateFormatter dateFromString:timeStr];
    NSTimeInterval timeSp = [date timeIntervalSince1970];
    return [NSString stringWithFormat:@"%f",timeSp];
}

#pragma mark 字符与字典的转换
//字符串转字典与字典转字符串
+ (NSDictionary *)parseJSONStringToNSDictionary:(NSString *)JSONString {
    NSData *JSONData = [JSONString dataUsingEncoding:NSUTF8StringEncoding];
    NSDictionary *responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil];
    return responseJSON;
}
+ (NSArray *)parseJSONStringToNSArray:(NSString *)JSONString {
    NSData *JSONData = [JSONString dataUsingEncoding:NSUTF8StringEncoding];
    NSArray *responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil];
    return responseJSON;
}
+ (NSString*)arrayToJson:(NSArray *)arr

{
    
    NSError *parseError = nil;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:arr options:NSJSONWritingPrettyPrinted error:&parseError];
    
    return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
}
+ (NSString*)dictionaryToJson:(NSDictionary *)dic

{
    
    NSError *parseError = nil;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];
    
    return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
}

#pragma mark GTMBase64
/**
 * GTM 编码
 */
+(NSString *)GTMEncodeTest:(NSString *)originStr

{
    NSString* encodeResult = nil;
    NSData* originData = [originStr dataUsingEncoding:NSUTF8StringEncoding];
    
    NSData* encodeData = [GTMBase64 encodeData:originData];
    
    encodeResult = [[NSString alloc] initWithData:encodeData encoding:NSUTF8StringEncoding];
    
    return encodeResult;
}
/**
 * GTM 解码
 */
+(NSString *)GMTDecodeTest:(NSString *)decodeStr

{
    NSString* decodeResult = nil;
    
    NSData* encodeData = [decodeStr dataUsingEncoding:NSUTF8StringEncoding];
    
    NSData* decodeData = [GTMBase64 decodeData:encodeData];
    
    decodeResult = [[NSString alloc] initWithData:decodeData encoding:NSUTF8StringEncoding];
    
    return decodeResult;
}

//修改图片尺寸
+ (NSData *)imageCompressForWidth:(UIImage *)sourceImage targetWidth:(CGFloat)defineWidth
{
    [sourceImage compressedImageByCtrl:400];
    CGSize imageSize = sourceImage.size;
    CGFloat width = imageSize.width;
    CGFloat height = imageSize.height;
    if (height > width) {
        if (height > defineWidth ) {
            CGFloat targetHeight = defineWidth;
            CGFloat targetWidth = (targetHeight/height)*width;
            
            UIGraphicsBeginImageContext(CGSizeMake(targetWidth, targetHeight));
            [sourceImage drawInRect:CGRectMake(0,0,targetWidth,  targetHeight)];
        }
        
    }else{
        if (width > defineWidth ) {
            CGFloat targetWidth = defineWidth;
            CGFloat targetHeight = (targetWidth / width) * height;
            UIGraphicsBeginImageContext(CGSizeMake(targetWidth, targetHeight));
            [sourceImage drawInRect:CGRectMake(0,0,targetWidth,  targetHeight)];
        }
        
        
    }
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    if (newImage) {
        if (UIImagePNGRepresentation(newImage)) {
            return UIImagePNGRepresentation(newImage);
        }else{
            return UIImageJPEGRepresentation(newImage, 0.5);
        }
    }else{
        if (UIImagePNGRepresentation(sourceImage)) {
            return UIImagePNGRepresentation(sourceImage);
        }else{
            return UIImageJPEGRepresentation(sourceImage, 0.5);
        }
    }
    
}

//判断对象是否为空
+ (NSString *)returnRealValue:(id)sendValue {
    if ([sendValue isKindOfClass:[NSNull class]] || sendValue == NULL) {
        return @"";
    }
    if ([sendValue isKindOfClass:[NSNumber class]]) {
        return [sendValue stringValue];
    }
    return sendValue;
}

#pragma 各种格式检验
//获取部分显示手机格式
+ (NSString *)getPhoneText:(NSString *)phoneNum {
    NSString *headStr = [phoneNum substringToIndex:3];//截取掉下标2之前的字符串
    NSString *backStr = [phoneNum substringFromIndex:7];//截取掉下标6之后的字符串
    
    return [NSString stringWithFormat:@"%@****%@",headStr,backStr];
}
//手机格式
+ (BOOL)phoneNum:(NSString *) textString {
    NSString *number = @"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";
    NSPredicate *numberPre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",number];
    return [numberPre evaluateWithObject:textString];
}
//数字检验
+ (BOOL)validateNumber:(NSString*)number {
    BOOL res = YES;
    NSCharacterSet* tmpSet = [NSCharacterSet characterSetWithCharactersInString:@".0123456789"];
    int i = 0;
    while (i < number.length) {
        NSString * string = [number substringWithRange:NSMakeRange(i, 1)];
        NSRange range = [string rangeOfCharacterFromSet:tmpSet];
        if (range.length == 0) {
            res = NO;
            break;
        }
        i++;
    }
    return res;
}
//判断输入的是否是表情
+(BOOL)isContainsEmoji:(NSString *)string {
    
    __block BOOL isEomji = NO;
    [string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
     ^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
         
         const unichar hs = [substring characterAtIndex:0];
         
         // surrogate pair
         
         if (0xd800 <= hs && hs <= 0xdbff) {
             
             if (substring.length > 1) {
                 
                 const unichar ls = [substring characterAtIndex:1];
                 
                 const int uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000;
                 
                 if (0x1d000 <= uc && uc <= 0x1f77f) {
                     
                     isEomji = YES;
                     
                 }
                 
             }
             
         } else if (substring.length > 1) {
             
             const unichar ls = [substring characterAtIndex:1];
             
             if (ls == 0x20e3) {
                 
                 isEomji = YES;
                 
             }
         } else {
             // non surrogate
             
             if (0x2100 <= hs && hs <= 0x27ff && hs != 0x263b) {
                 isEomji = YES;
             } else if (0x2B05 <= hs && hs <= 0x2b07) {
                 isEomji = YES;
             } else if (0x2934 <= hs && hs <= 0x2935) {
                 isEomji = YES;
             } else if (0x3297 <= hs && hs <= 0x3299) {
                 isEomji = YES;
             } else if (hs == 0xa9 || hs == 0xae || hs == 0x303d || hs == 0x3030 || hs == 0x2b55 || hs == 0x2b1c || hs == 0x2b1b || hs == 0x2b50|| hs == 0x231a ) {
                 isEomji = YES;
             }
         }
     }];
    return isEomji;
    
}
//身份证号
+ (BOOL) validateIdentityCard: (NSString *)identityCard
{
    BOOL flag;
    if (identityCard.length <= 0) {
        flag = NO;
        return flag;
    }
    NSString *regex2 = @"^(\\d{14}|\\d{17})(\\d|[xX])$";
    NSPredicate *identityCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2];
    return [identityCardPredicate evaluateWithObject:identityCard];
}
+ (BOOL)ConformToTheMoneyInputString:(NSString *)string shouldChangeCharactersInRange:(NSRange)range currtentTextField:(UITextField *)textField{
    BOOL isHavePoint = NO;
    if ([textField.text rangeOfString:@"."].location == NSNotFound) {
        isHavePoint = NO;
    }else{
        isHavePoint = YES;
    }
    if ([string length] > 0) {
        if ([string length] != 1) {
            return NO;
        }
        unichar single = [string characterAtIndex:0];//当前输入的字符
        if ((single >= '0' && single <= '9') || single == '.') {//数据格式正确
            //首字母不能为0和小数点
            if([textField.text length] == 0){
                if(single == '.') {
                    return NO;
                }
                //                if (single == '0') {
                //                    return NO;
                //                }
            }
            //输入的字符是否是小数点
            if (single == '.') {
                if(!isHavePoint)//text中还没有小数点
                {
                    isHavePoint = YES;
                    return YES;
                    
                }else{
                    return NO;
                }
            }else{
                if (isHavePoint) {//存在小数点
                    //判断小数点的位数
                    NSRange ran = [textField.text rangeOfString:@"."];
                    if (range.location - ran.location <= 2) {
                        return YES;
                    }else{
                        return NO;
                    }
                }else{
                    return YES;
                }
            }
        }else{//输入的数据格式不正确
            return NO;
        }
    }
    return YES;
    
}


#pragma 缓存文件处理
+ (float)getCacheSize{
    // 获取Caches目录路径
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask,YES);
    NSString *cachesDir = [paths objectAtIndex:0];
    
    NSFileManager* manager = [NSFileManager defaultManager];
    if (![manager fileExistsAtPath:cachesDir]) return 0;
    NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath:cachesDir] objectEnumerator];//从前向后枚举器
    NSString* fileName;
    long long folderSize = 0;
    while ((fileName = [childFilesEnumerator nextObject]) != nil){
        NSLog(@"fileName ==== %@",fileName);
        NSString* fileAbsolutePath = [cachesDir stringByAppendingPathComponent:fileName];
        NSLog(@"fileAbsolutePath ==== %@",fileAbsolutePath);
        CGFloat size = 0;
        NSFileManager* manager = [NSFileManager defaultManager];
        if ([manager fileExistsAtPath:fileAbsolutePath]){
            size = [[manager attributesOfItemAtPath:fileAbsolutePath error:nil] fileSize];
        }
        folderSize += size;
    }
    NSLog(@"folderSize ==== %lld",folderSize);
    return folderSize/(1024.0*1024.0);
}
+ (void)clearCache{
    // 获取Caches目录路径
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask,YES);
    NSString *cachesDir = [paths objectAtIndex:0];
    //清除缓存
    NSFileManager *fileManager=[NSFileManager defaultManager];
    if ([fileManager fileExistsAtPath:cachesDir]) {
        NSArray *childerFiles=[fileManager subpathsAtPath:cachesDir];
        for (NSString *fileName in childerFiles) {
            //如有需要，加入条件，过滤掉不想删除的文件
            NSString *absolutePath=[cachesDir stringByAppendingPathComponent:fileName];
            [fileManager removeItemAtPath:absolutePath error:nil];
        }
    }
}

//判断系统版本
+(int)osVersion
{
    //使用UIDevice设别类获取版本, 名字.....
    return [[[UIDevice currentDevice] systemVersion] intValue];
}
//更新系统版本
+ (void)updateSystemVersion:(NSString *)appId success:(SuccessBlock)successBlock fail:(FailBlock)failBlock{
    [NetRequest getDataWithUrlString:@"http://itunes.apple.com/lookup" withParams:@{@"id":appId} success:^(id data) {
        
        NSLog(@"data is %@",data);
        
        NSDictionary *versions = data[@"results"][0];
        NSString *version = versions[@"version"];
        
        NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
        CFShow((__bridge CFTypeRef)(infoDictionary));
        // app版本
        NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
        
        if ([app_Version floatValue] < [version floatValue]) {
            
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@",appId]]];
        }else {
            
        }
        successBlock(data);
        //
        
    } fail:^(NSString *errorDes) {
        failBlock(errorDes);
    }];
}

+ (UILabel *)versionLabel {
    UILabel *label = [UILabel labelWithFrame:CGRectMake((screen_width-200)/2, screen_height-60, 200, 60) text:@"版权所有 Copyright©\n小白鼠版权所有" font:12.0f textColor:color(178,168,168,1)];
    NSString *labelText = @"版权所有 Copyright©\n小白鼠版权所有";
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    
    [paragraphStyle setLineSpacing:5];//调整行间距
    
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [labelText length])];
    label.attributedText = attributedString;
    label.textAlignment = 1;
    label.numberOfLines = 2;
    return label;
}

+ (void)jumpToTabbarVC {
    TabBarViewController *vc = [[TabBarViewController alloc] init];
    double delayInSeconds = 1.0;
    //                    __block LoginViewController* bself = self;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        AppDelegateInstance.window.rootViewController = nil;
        AppDelegateInstance.window.rootViewController = vc;
    });
}

// 设置本地通知
+ (void)registerLocalNotification:(NSDate*)alertDate alertBody:(NSString *)alertBody userDict:(NSDictionary *)userDict
{
    UILocalNotification *notification = [[UILocalNotification alloc] init];
    // 设置触发通知的时间
    NSDate *fireDate = alertDate;
    NSLog(@"data :%@",fireDate);
    notification.fireDate = fireDate;
    // 时区
    notification.timeZone = [NSTimeZone defaultTimeZone];
    // 设置重复的间隔
    notification.repeatInterval = kCFCalendarUnitSecond;
    
    // 通知内容
    notification.alertBody = alertBody;
    notification.applicationIconBadgeNumber = 1;
    // 通知被触发时播放的声音
    notification.soundName = UILocalNotificationDefaultSoundName;
    // 通知参数
    notification.userInfo = userDict;
    
    // ios8后，需要添加这个注册，才能得到授权
    if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
    {
        UIUserNotificationType type =  UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:type categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
        // 通知重复提示的单位，可以是天、周、月
        notification.repeatInterval = NSCalendarUnitDay;
    }
    else
    {
        // 通知重复提示的单位，可以是天、周、月
        notification.repeatInterval = NSDayCalendarUnit;
    }
    
    // 执行通知注册
    [[UIApplication sharedApplication] scheduleLocalNotification:notification];
}

// 取消某个本地推送通知
+ (void)cancelLocalNotificationWithKey:(NSString *)key
{
    // 获取所有本地通知数组
    NSArray *localNotifications = [UIApplication sharedApplication].scheduledLocalNotifications;
    
    for (UILocalNotification *notification in localNotifications)
    {
        NSDictionary *userInfo = notification.userInfo;
        if (userInfo)
        {
            // 根据设置通知参数时指定的key来获取通知参数
            NSString *info = userInfo[key];
            
            // 如果找到需要取消的通知，则取消
            if (info != nil)
            {
                [[UIApplication sharedApplication] cancelLocalNotification:notification];
                break;
            }
        }
    }
}

//登陆里的控件创建
+ (UITextField *)createTextField:(CGRect)frame withLeftView:(UIView *)leftView withPlaceholder:(NSString *)placeholder withDelegate:(id)target{
    UITextField *textField = [[UITextField alloc] initWithFrame:frame];
    textField.font = [UIFont systemFontOfSize:16.0f];
    textField.layer.cornerRadius = 5;
    textField.background = [[UIImage imageNamed:@"rr_pub_button_silver.png"] stretchableImageWithLeftCapWidth:5 topCapHeight:5];
    textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    textField.autocapitalizationType = YES;
    textField.minimumFontSize = 10;
    textField.placeholder = placeholder;
    textField.leftView = leftView;
    textField.leftViewMode = UITextFieldViewModeAlways;
    textField.delegate = target;
    return textField;
}

//登陆按钮
+ (UIButton *)createBtn:(CGRect)frame withTitle:(NSString *)title target:(id)target withSel:(SEL)sel withTitleColor:(UIColor *)color withBackColor:(UIColor *)backColor{
    UIButton *logInBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    logInBtn.frame = frame;
    [logInBtn setTitle:title forState:UIControlStateNormal];
    [logInBtn setTitleColor:color forState:UIControlStateNormal];
    [logInBtn addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
    logInBtn.backgroundColor = backColor;
    logInBtn.titleLabel.font = boldSystemFont(18.0f);
    logInBtn.layer.cornerRadius = 5;
    
    //额外设置
    [logInBtn setTitleColor:red_color forState:UIControlStateSelected];
    [logInBtn setTitle:@"删除" forState:UIControlStateSelected];
    
    return logInBtn;
}

#pragma mark -- 登陆界面控件
//登陆
+ (UIView *)createLoginView:(CGRect)frame withCore:(BOOL)isCore{
    UIView *view = [[UIView alloc] initWithFrame:frame];
    if (isCore) {
        view.layer.cornerRadius = 5;
    }
    view.layer.borderColor = color(0, 0, 0, 0.1).CGColor;
    view.layer.borderWidth = 0.5;
    view.clipsToBounds = YES;
    view.backgroundColor = [UIColor whiteColor];
    return view;
}
//登陆小控件
+ (UILabel *)createLabel:(CGRect)frame withTitle:(NSString *)title withFont:(float)fontSize{
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.textColor = color(0, 0, 0, 0.8);
    label.text = title;
    label.font = [UIFont systemFontOfSize:fontSize];
    return label;
}

//发布页面输入框
+ (UITextField *)createTextField:(CGRect)frame withPlaceholder:(NSString *)placeholder withLeftViewTitle:(NSString *)title withLeftViewTitleColor:(UIColor *)titleColor withLeftFont:(float)fontSize withLeftViewWidth:(float)width withDelegate:(id)target{
    UITextField *textField = [[UITextField alloc] initWithFrame:frame];
    textField.font = systemFont(fontSize);
    textField.backgroundColor = [UIColor whiteColor];
    textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    textField.autocapitalizationType = YES;
    textField.minimumFontSize = 10;
    textField.placeholder = placeholder;
    textField.delegate = target;
    CGFloat w = width;
    if (width == -1) {
        w = [MYFactoryManager widthForString:title fontSize:fontSize andHeight:frame.size.height]+10;
    }
    UILabel *leftLabel = [UILabel labelWithFrame:CGRectMake(0, 0, w, frame.size.height) text:title font:fontSize textColor:titleColor];
    leftLabel.textAlignment = 1;
    textField.leftView = leftLabel;
    textField.textColor = [UIColor grayColor];
    textField.leftViewMode = UITextFieldViewModeAlways;
    return textField;
}

+ (void)showFrameAnimationBubble:(UIButton *)sender {
    LKBubbleInfo *frameInfo = [[LKBubbleInfo alloc] init];
    NSMutableArray<UIImage *> *icons = [[NSMutableArray alloc] init];
    for (int i = 1 ; i <= 8; i ++) {
        [icons addObject: [UIImage imageNamed: [NSString stringWithFormat: @"lkbubble%d.jpg" , i]]];
    }
    frameInfo.iconArray = icons;
    // 在数组中依次放入多张图片即可实现多图循环播放
    frameInfo.backgroundColor = [UIColor colorWithRed: 238 / 255.0 green:238 / 255.0 blue:238 / 255.0 alpha:1];
    // 动画的帧动画播放间隔
    frameInfo.frameAnimationTime = 0.15;
    frameInfo.title = @"正在加载中...";
    frameInfo.titleColor = [UIColor darkGrayColor];
    [[LKBubbleView defaultBubbleView] showWithInfo: frameInfo];
}

+ (void)hideBubbleFrame:(float)intetval {
    [[LKBubbleView defaultBubbleView] performSelector:@selector(hideBubble) withObject:nil afterDelay:intetval];
}

@end
